package com.xfcy.blog.entity;


import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * (AdminLog)表实体类
 *
 * @author 晓风残月Lx
 * @since 2023-04-09 10:59:51
 */
@TableName("b_admin_log")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AdminLog implements Serializable {
    //主键ID
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    //操作用户
    private String username;
    //请求接口
    private String requestUrl;
    //请求方式
    private String type;
    //操作名称
    private String operationName;
    //ip
    private String ip;
    //ip来源
    private String source;
    //请求接口耗时
    private Long spendTime;
    //创建时间
    private LocalDateTime createTime;
    //请求参数
    private String paramsJson;
    //类地址
    private String classPath;
    //方法名
    private String methodName;

    public AdminLog(String ip, String source, String type, String requestUrl, String nickname,
                    String paramsJson, String classPath,
                    String methodName, String operationName,
                    LocalDateTime createTime,
                    Long spendTime) {
        this.ip = ip;
        this.source = StringUtils.isBlank(source) ? "未知": source;
        this.type = type;
        this.requestUrl = requestUrl;
        this.username = nickname;
        this.paramsJson = paramsJson;
        this.classPath = classPath;
        this.methodName = methodName;
        this.operationName = operationName;
        this.createTime = createTime;
        this.spendTime = spendTime;
    }
}

